package com.lvw.weather.forcast.web;

import com.lvw.weather.dto.Weather;
import com.lvw.weather.forcast.web.fallback.ForcastAPIFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Primary
@FeignClient(name = "weather-forcast-service", fallback = ForcastAPIFallback.class)  // This is must be.
public interface IForcastAPI {

    @RequestMapping("/forcast/{city}")
    String forcast(@PathVariable String city);

    @RequestMapping("/forcast")
    List<String> forcasts(@RequestParam List<String> citys);

    @RequestMapping(value = "/forcast/update", method = RequestMethod.POST)
    boolean updateForcast(@RequestHeader("city") String city, @RequestBody Weather weather);
}
